package com.cloudfun.campusshare.repo;

import com.cloudfun.campusshare.common.constant.AsyncTaskBizType;
import com.cloudfun.campusshare.common.constant.AsyncTaskStatus;
import com.cloudfun.campusshare.entity.AsyncTaskEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Collection;
import java.util.List;

/**
 * Created by CodeGenerator on 2020/06/04
 */
public interface AsyncTaskRepo extends PagingAndSortingRepository<AsyncTaskEntity, String>, JpaSpecificationExecutor<AsyncTaskEntity> {

    AsyncTaskEntity findTopByBizTypeAndBizIdOrderByCreateTimeDesc(AsyncTaskBizType bizType, String bizId);

    List<AsyncTaskEntity> findAllByBizTypeAndStatusNotIn(AsyncTaskBizType bizType, Collection<AsyncTaskStatus> status);

    List<AsyncTaskEntity> findAllByBizTypeAndBizIdAndStatusNotIn(AsyncTaskBizType bizType, String bizId, Collection<AsyncTaskStatus> status);

}